/***************************************************************************
 * 文件名：FMAddAssemblyReference
 * 功能：
 * 说明：添加程序集信息
 * -------------------------------------------------------------------------
 * 创建时间：2025/7/14 19:35:46
 * 创建人：葛浩
 * 邮箱： 2094733071@qq.com
 * =========================================================================
 *
 * 修改人：   
 * 修改时间：   
 * 修改说明：   
 ***************************************************************************/
using DevExpress.XtraEditors;
using System;
using System.IO;
using System.Windows.Forms;

namespace BuiltInTools
{
	public partial class FMAddAssemblyReference : XtraForm
	{
		/// <summary>
		/// 名称
		/// </summary>
		public string AssemblyName { get { return this.txtAssemblyName.Text ?? string.Empty; } }

		/// <summary>
		/// 路径
		/// </summary>
		public string HintPath { get { return this.txtPath.Text ?? string.Empty; } }

		public FMAddAssemblyReference()
		{
			InitializeComponent();
		}

		/// <summary>
		/// 选择路径
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void btnSelectPath_Click(object sender, EventArgs e)
		{
			try
			{
				OpenFileDialog fileDialog = new OpenFileDialog();

				fileDialog.Filter = "dll 文件|*.dll";

				if (fileDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
				{
					return;
				}

				this.txtPath.Text = fileDialog.FileName;
				this.txtAssemblyName.Text = Path.GetFileName(fileDialog.FileName);
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
			}
		}

		/// <summary>
		/// 确认
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void btnConfirm_Click(object sender, EventArgs e)
		{
			if (string.IsNullOrEmpty(AssemblyName))
			{
				MessageBox.Show("名称不能为空！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
				return;
			}

			if (string.IsNullOrEmpty(HintPath))
			{
				MessageBox.Show("路径不能为空！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
				return;
			}

			DialogResult = DialogResult.OK;
		}

		/// <summary>
		/// 关闭
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void btnClose_Click(object sender, EventArgs e)
		{
			DialogResult = DialogResult.Cancel;
		}
	}
}
